<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.org/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximumscale=1">
    <title>layui布局</title>
    <!--第一步，引入layui的资源-->
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}">
</head>
<body>
<form class="layui-form" action=" " id="applyList" th:inline="none">
    <div class="layui-form-item">
        <label class="layui-form-label">车牌号码</label>
        <div class="layui-input-block" >
            <select id="vid">
                <option value="0">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门</label>
        <div class="layui-input-block" >
            <select id="did">
                <option value="0">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出车时间</label>
        <div class="layui-input-block">
            <input type="Date" id="outtime"  name="outtime" required  lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">预计时间</label>
        <div class="layui-input-block">
            <input type="Date"  id="predicttime" name="predicttime" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">随行人员</label>
        <div class="layui-input-block">
            <input type="text"  id="otherpeople" name="otherpeople" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">驾驶员</label>
        <div class="layui-input-block" >
            <select id="driverid">
                <option value="0">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">目的地</label>
        <div class="layui-input-block">
            <input type="text"  id="destination" name="destination " required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出车原因</label>
        <div class="layui-input-block">
            <input type="text"  id="outwhy" name="outwhy" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
</form>
<!--在body下引入js资源-->
<script th:src="@{/resources/layui/layui.js}"></script>
<!--开始写，layui的资源-->
<script th:inline="none">//此处有坑，需要设置“th:inline="none"”
//一般直接写在一个js文件中
//同时，在layui中引入table表格
layui.use(['layer', 'form', 'table'], function () {
    var layer = layui.layer
        , form = layui.form
        , table = layui.table
        , $ = layui.jquery;

    $.ajax({
        url: "/vehiclefiles/selectVehicleAll",
        type: "get",
        success: function (res) {
            var vehiclefiles = res.data.vehiclefiles;

            if (vehiclefiles.length > 0) {
                for (var i = 0; i < vehiclefiles.length; i++) {
                    var vehicle = vehiclefiles[i];
                    $("#vid").append("<option value='" + vehicle.id + "'>" + vehicle.vehiclenum + "</option> ")
                }
            }
            //渲染下拉菜单 下拉菜单都必须得渲染
            layui.form.render("select");
        }
    });
    $.ajax({
        url: "/dept/deptselectAll",
        type: "get",
        success: function (res) {
            var depts = res.data.depts;

            if (depts.length > 0) {
                for (var i = 0; i < depts.length; i++) {
                    var dept = depts[i];
                    $("#did").append("<option value='" + dept.id + "'>" + dept.name + "</option> ")
                }
            }
            //渲染下拉菜单 下拉菜单都必须得渲染
            layui.form.render("select");
        }
    });
    $.ajax({
        url: "/driver/selectAllDriver",
        type: "get",
        success: function (res) {
            var drivers = res.data.drivers;
            console.log(res)
            if (drivers.length > 0) {
                for (var i = 0; i < drivers.length; i++) {
                    var driver = drivers[i];
                    $("#driverid").append("<option value='" + driver.id + "'>" + driver.name + "</option> ")
                }
            }
            //渲染下拉菜单 下拉菜单都必须得渲染
            layui.form.render("select");
        }

    });
});
var callbackdata=function(){
    //返回值没有data的话父页面拿不到id的值
    var vid=document.getElementById('vid').value;
    var did=document.getElementById('did').value;
    var outtime=document.getElementById('outtime').value;
    var predicttime=document.getElementById('predicttime').value;
    var otherpeople=document.getElementById('otherpeople').value;
    var driverid=document.getElementById('driverid').value;
    var destination=document.getElementById('destination').value;
    var outwhy=document.getElementById('outwhy').value;
    var obj={
        vid:vid,
        did:did,
        outtime:outtime,
        predicttime:predicttime,
        otherpeople:otherpeople,
        driverid:driverid,
        destination:destination,
        outwhy:outwhy,
    }
    return obj;
}
    //引入jquery
</script>
</body>
</html>